//
//  EquipmentService.m
//  AILock
//
//  Created by 谭亚明 on 2020/7/6.
//  Copyright © 2020 tym. All rights reserved.
//

#import "EquipmentService.h"
#import "EquipmentTypeModel.h"
#import "YYModel.h"
#import "EquipmentMessageModel.h"
#import "NSString+Option.h"

@implementation EquipmentService

/*修改设备用户名称*/
-(void)getEquipmentEquipmentUserAuthId:(NSInteger)authId
equipmentUserName:(NSString*)equipmentUserName
                            completion:(void(^)(LMJBaseResponse*resp))completion{
    
    NSDictionary *dic = @{@"equipmentUserAuthId":@(authId),
                          @"equipmentUserName":equipmentUserName,
    };
    [self POST:urlEquipmentuserupdatelockusername parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
    
}

/*获取系统字典*/
-(void)getEquipmentSysDictdictType:(NSString*)dictType
                        completion:(void(^)(LMJBaseResponse*resp,NSArray<EquSubSysDict*>*  sysArray))completion{
    
    
    NSDictionary *dic = @{@"dictType":dictType
    };
    [self GET:urlSysdictfindsysdictbytype parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[NSArray yy_modelArrayWithClass:[EquSubSysDict class] json:response.responseObject[@"data"]]);
    }];
}

/*创建设备保修申请*/
-(void)getCreateequipmentrepairsapplyID:(NSInteger)equipmentId mobile:(NSString *)mobile userName:(NSString *)userName address:(NSString *)address phots:(NSString *)photoStr video:(NSString *)videoStr applyDesc:(NSString *)applyDesc provinceCode:(NSInteger)provincecode province:(NSString *)province cityCode:(NSInteger)cityCode city:(NSString *)city districtCode:(NSString*)districtCode district:(NSString *)district rentLng:(NSString *)rentLng rentLat:(NSString *)rentLat completion:(void (^)(LMJBaseResponse * _Nonnull))completion{

    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"imageUrl":photoStr?photoStr:@"",
                          @"videoUrl":videoStr?videoStr:@"",
                          @"mobile":mobile,
                          @"userName":userName,
                          @"district":district,
                          @"address":address,
                          @"applyDesc":applyDesc,
                         // @"provinceCode":@(provincecode),
                          @"province":province,
                        //  @"cityCode":@(cityCode),
                          @"city":city,
                          @"districtCode":districtCode,
                          @"district":district,
                          @"rentLng":rentLng,
                          @"rentLat":rentLat
    };
    [self POST:urlCreateequipmentrepairsapply parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
    
}

/*获取开关锁状态*/
-(void)getEquipmentequipmentId:(NSInteger)equipmentId
                    completion:(void(^)(LMJBaseResponse*resp,EquipmentModel *equipment))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId)};
    [self POST:urlGetopenclosedoorstatus parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[EquipmentModel yy_modelWithJSON: response.responseObject[@"data"]]);
    }];
}

/*远程开锁*/
-(void)getOpenclosedoorapplyequipmentId:(NSInteger)equipmentId commandType:(NSInteger)commandType
operationPassword:(NSString*)operationPassword
                             completion:(void(^)(LMJBaseResponse  *respons))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"commandType":@(commandType),@"operationPassword":operationPassword};
    [self POST:urlOpenclosedoorapply parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
}

//添加设备
-(void)getAddEquipmentWithType:(NSInteger)equipmentTypeId
                    macAddress:(NSString*)macAddress
                     ipAddress:(NSString*)ipAddress
                  familyRoomId:(NSInteger)familyRoomId
                      familyId:(NSInteger)familyId
                      wifiName:(NSString*)wifiName
                    completion:(void(^)(NSError *error, LMJBaseResponse *response))completion{
    
    NSDictionary *dic = @{@"equipmentTypeId":@(equipmentTypeId),
                          @"macAddress":macAddress,@"ipAddress":ipAddress?ipAddress:@"",
                          @"familyId":@(familyId),
                          @"wifiName":wifiName};
    [self POST:urlCreateequipment parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response.error,response);
    }];
}


/*查找设备类型*/
-(void)getFindequipmenttypelistcompletion:(void(^)(NSError *error,NSArray<EquipmentTypeModel*>  *array))completion{
    
    [self POST:urlFindequipmenttypelist parameters:nil completion:^(LMJBaseResponse *response) {
       completion(response.error,[NSArray yy_modelArrayWithClass:[EquipmentTypeModel class] json:response.responseObject[@"data"]]);
    }];
}

/*移动设备*/
-(void)getMoveEquipment:(NSArray*)ids
  familyRoomId:(NSInteger)familyRoomId
             completion:(void(^)(LMJBaseResponse *response))completion{
    
    NSDictionary *dic = @{@"ids":[ids componentsJoinedByString:@","],
                          @"familyRoomId":@(familyRoomId)};
    [self POST:urlMoveequipment parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
}

/*修改设备信息*/
-(void)getUpdateequipment:(NSInteger)ids
  name:(NSString*)name
             completion:(void(^)(NSError *error, LMJBaseResponse *response))completion{
    
    NSDictionary *dic = @{@"id":@(ids),
                          @"name":name};
    [self POST:urlUpdateequipment parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response.error,response);
    }];
}

/*获取不是此房间的家庭设备*/
-(void)getNOroomequipments:(NSInteger)familyRoomId
              completion:(void(^)(NSError *error,NSArray<EquipmentModel*>  *array))completion{
    
    NSDictionary *dic = @{@"familyRoomId":@(familyRoomId)};
    [self GET:urlGetNoRoomEquipments parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response.error,[NSArray yy_modelArrayWithClass:[EquipmentModel  class] json:response.responseObject[@"data"]]);
    }];
}

/*获取房间所有设备*/
-(void)getRoomequipments:(NSInteger)familyRoomId
              completion:(void(^)(LMJBaseResponse *respon,NSArray<EquipmentModel*>  *array))completion{
    
    NSDictionary *dic = @{@"familyRoomId":@(familyRoomId)};
    [self GET:urlRoomequipments parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response,[NSArray yy_modelArrayWithClass:[EquipmentModel  class] json:response.responseObject[@"data"]]);
    }];
}

/*获取设备详情*/
-(void)getEquipmentinfo:(NSInteger)equipmentId
              completion:(void(^)(NSError *error,EquipmentModel  *equipmentModel))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId)};
    [self GET:urlEquipmentinfo parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response.error,[EquipmentModel yy_modelWithJSON: response.responseObject[@"data"]]);
    }];
}

/*获取设备配置详情*/
-(void)getEquipmentconfiginfo:(NSInteger)equipmentId
                   completion:(void(^)(NSError *error,Equipmentconfig  *equipmentConfig))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId)};
    [self GET:urlEquipmentconfiginfo parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response.error,[Equipmentconfig yy_modelWithJSON: response.responseObject[@"data"]]);
    }];
}

-(void)getDeleteEquimpentWithID:(NSInteger)equipmentId completion:(void(^)(LMJBaseResponse  *respons))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId)};
    [self POST:urlDeleteequipment parameters:dic completion:^(LMJBaseResponse *response) {
       completion([LMJBaseResponse yy_modelWithJSON:response.responseObject]);
    }];
}

//获取地址对象
-(void)getAddressWithType:(NSInteger)type code:(NSString*)code
               completion:(void(^)(LMJBaseResponse *respons,NSArray<AddRessModel*>  *array))completion{
    
    NSDictionary *dic = @{@"type":@(type),
                          @"code":code?code:@""
    };
    [self GET:urlAreaInfoAll parameters:dic completion:^(LMJBaseResponse *response) {
       completion([LMJBaseResponse yy_modelWithJSON:response.responseObject],[NSArray yy_modelArrayWithClass:[AddRessModel class] json:response.responseObject[@"data"]]);
    }];
}

/*提示音管理*/
-(void)getWarningtonemanagereEuipmentId:(NSInteger)equipmentId action:(NSString*)action
parameteType:(NSString*)parameterType
parmeteValue:(NSString*)parameterValue
                             completion:(void(^)(LMJBaseResponse *respons))completion{
    
    
}

/*开门方式*/
-(void)getOpendoorwayEuipmentId:(NSInteger)equipmentId action:(NSString*)action
parameteType:(NSString*)parameterType
parmeteValue:(NSString*)parameterValue
                     completion:(void(^)(LMJBaseResponse *respons))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"action":action,
                          @"parameterType":parameterType,
                          @"parameterValue":parameterValue
    };
    [self POST:urlOpendoorway parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
}


/*信息推送*/
-(void)getInformationpushEuipmentId:(NSInteger)equipmentId action:(NSString*)action
parameteType:(NSString*)parameterType
parmeteValue:(NSString*)parameterValue
                         completion:(void(^)(LMJBaseResponse *respons))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"action":action,
                          @"parameterType":parameterType,
                          @"parameterValue":parameterValue
    };
    [self POST:urlInformationpush parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
}

/*远程开门权限*/
-(void)getRemoteaccesspermissionEuipmentId:(NSInteger)equipmentId action:(NSString*)action
parmeteValue:(NSString*)parameterValue
                                completion:(void(^)(LMJBaseResponse *respons))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"action":action,
                          @"parameterValue":parameterValue
    };
    [self POST:urlRemoteaccesspermission parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
}

/*开锁参数*/
-(void)getOpenlockparameterEuipmentId:(NSInteger)equipmentId action:(NSString*)action
parameteType:(NSString*)parameterType
parmeteValue:(NSString*)parameterValue
                           completion:(void(^)(LMJBaseResponse *respons))completion{
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"action":action,
                          @"parameterType":parameterType,
                          @"parameterValue":parameterValue
    };
    [self POST:urlOpenlockparameter parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
}

/*提示音管理*/
-(void)getWarningtonemanagerEuipmentId:(NSInteger)equipmentId action:(NSString*)action
parameteType:(NSString*)parameterType
parmeteValue:(NSString*)parameterValue
                            completion:(void(^)(LMJBaseResponse *respons))completion{
    
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"action":action,
                          @"parameterType":parameterType,
                          @"parameterValue":parameterValue
    };
    [self POST:urlWarningtonemanager parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
}

/*设备用户(指纹/密码/卡片)列表*/
-(void)getEquipmentuserList:(NSInteger)equipmentId equipmentUserType:(NSString*)equipmentUserType
userId:(NSInteger)userId
type:(NSInteger)type
                 completion:(void(^)(LMJBaseResponse *respons,NSArray<EquipmentUserModel*>*array))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"equipmentUserType":equipmentUserType,
                          @"userId":@(userId),
                          @"type":@(type)
    };
    [self GET:urlEquipmentuserlist parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[NSArray yy_modelArrayWithClass:[EquipmentUserModel class] json:response.responseObject[@"data"][@"content"]]);
    }];
}

/*获取设备用户（指纹，密码，卡）详情*/
-(void)getEquipmentusergetdetail:(NSInteger)equipmentUserId
                      completion:(void(^)(LMJBaseResponse *respons,EquipmentUserModel*userModel))completion{
    
    NSDictionary *dic = @{@"id":@(equipmentUserId)
    };
    [self GET:urlEquipmentusergetdetail parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[EquipmentUserModel yy_modelWithJSON:response.responseObject[@"data"]]);
    }];
    
}

/*设备用户-每个类型的列表*/
-(void)getEquipmentuserlistgroupallEquipment:(NSInteger)equipmentId
type:(NSInteger)type
                                  completion:(void(^)(LMJBaseResponse *respons,EquUsers *users ))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"type":@(type)
    };
    [self GET:urlListgroupall parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response,[EquUsers yy_modelWithJSON:response.responseObject[@"data"]]);
    }];
    
}

/*设备关联用户列表*/
-(void)getEquipmentuseruserlistEquipment:(NSInteger)equipmentId
type:(NSInteger)type
                              completion:(void(^)(LMJBaseResponse *respons,NSArray <UserModel*>*array))completion{
    NSDictionary *dic;
    if (type) {
       dic = @{@"equipmentId":@(equipmentId),
                                 @"type":@(type)
           };
    }else{
        dic = @{@"equipmentId":@(equipmentId)
                  };
    }
    
    [self GET:urlEquipmentuseruserlist parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response,[NSArray yy_modelArrayWithClass:[UserModel class] json:response.responseObject[@"data"]]);
    }];
    
}

/*设备关联用户详情*/
-(void)getEquipmentuseruserdetail:(NSInteger)equipmentId
userId:(NSInteger)userId
type:(NSInteger)type
                       completion:(void(^)(LMJBaseResponse *respons,UserModel *usermodel))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"userId":@(userId),
                          @"type":@(type)
    };
    [self GET:urlEquipmentuseruserdetail parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response,[UserModel yy_modelWithJSON:response.responseObject[@"data"]]);
    }];
}

/*获取家庭所有用户列表（家庭成员、游客用户）*/
-(void)getEquipmentuseruserall:(NSInteger)equipmentId
familyId:(NSInteger)familyId
                    completion:(void(^)(LMJBaseResponse *respons, NSArray<UserModel*> *users))completion{
    
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"familyId":@(familyId)
    };
    [self GET:urlEquipmentuseruserall parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response,[NSArray yy_modelArrayWithClass:[UserModel class] json:response.responseObject[@"data"]]);
    }];
}

/*添加指纹锁用户*/
-(void)getEquipmentAdduserlockequipmentId:(NSInteger)equipmentId
equipmentUserType:(NSString*)equipmentUserType
effectiveTime:(NSString*)effectiveTime
userRole:(NSInteger)userRole
startTime:(NSString*)startTime
endTime:(NSString*)endTime
                                    start:(NSString*)start
                                      end:(NSString*)end
validWeek:(NSString*)validWeek
type:(NSInteger)type
userId:(NSInteger)userId
                                     name:(NSString*)name
                               completion:(void(^)(LMJBaseResponse *respons))completion{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithDictionary: @{@"equipmentId":@(equipmentId),
                                                                                  @"equipmentUserType":equipmentUserType,
                                                                                  @"effectiveTime":effectiveTime,
                                                                                  @"userRole":@(userRole),
                                                                                  @"startTime":startTime?startTime:@"",
                                                                                  @"endTime":endTime?endTime:@"",
                                                                                  @"start":start?start:@"",
                                                                                  @"end":end?end:@"",
                                                                                  @"validWeek":validWeek,
                                                                                  @"type":@(type),
                                                                                  @"userId":@(userId),
                                                                                  @"equipmentUserName":name
    }];
    
    if ([effectiveTime isEqualToString:@"00"]) {
        [dic removeObjectForKey:@"endTime"];
        [dic removeObjectForKey:@"startTime"];
        [dic removeObjectForKey:@"start"];
        [dic removeObjectForKey:@"end"];
    }else if ([effectiveTime isEqualToString:@"01"]){
        [dic removeObjectForKey:@"start"];
        [dic removeObjectForKey:@"end"];
    }else if ([effectiveTime isEqualToString:@"02"]){
        [dic removeObjectForKey:@"endTime"];
        [dic removeObjectForKey:@"startTime"];
    }
    [self POST:urlAdduserlock parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
}

/*修改指纹锁用户*/
-(void)getEquipmentUpdateuserlockpmentId:(NSInteger)equipmentId
effectiveTime:(NSString*)effectiveTime
userRole:(NSInteger)userRole
startTime:(NSString*)startTime
endTime:(NSString*)endTime
validWeek:(NSString*)validWeek
equipmentUserAuthId:(NSInteger)equipmentUserAuthId
                                    star:(NSString*)star
                                     end:(NSString*)end
equipmentUserName:(NSString*)equipmentUserName
                              completion:(void(^)(LMJBaseResponse *respons))completion{
    
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithDictionary:@{@"equipmentId":@(equipmentId),
                          @"effectiveTime":effectiveTime,
                          @"userRole":@(userRole),
                                                                                 @"startTime":startTime?startTime:@"",
                                                                                 @"endTime":endTime?endTime:@"",
                          @"validWeek":validWeek,
                          @"equipmentUserAuthId":@(equipmentUserAuthId),
                          @"equipmentUserName":equipmentUserName,
                                                                                 @"start":star?star:@"",
                                                                                 @"end":end?end:@""
    }];
    
    if ([effectiveTime isEqualToString:@"00"]) {
        [dic removeObjectForKey:@"endTime"];
        [dic removeObjectForKey:@"startTime"];
        [dic removeObjectForKey:@"start"];
        [dic removeObjectForKey:@"end"];
    }else if ([effectiveTime isEqualToString:@"01"]){
        [dic removeObjectForKey:@"start"];
        [dic removeObjectForKey:@"end"];
    }else if ([effectiveTime isEqualToString:@"02"]){
        [dic removeObjectForKey:@"endTime"];
        [dic removeObjectForKey:@"startTime"];
    }
    
    [self POST:urUpdateuserlock parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
    
}

/*删除指纹锁用户*/
-(void)getEquipmentdeleteuserlockEpumentId:(NSInteger)equipmentId
equipmentUserIDs:(NSString*)equipmentUserIDs
                                completion:(void(^)(LMJBaseResponse *respons))completion{
    
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"equipmentUserIDs":equipmentUserIDs
    };
    [self POST:urlDeleteuserlock parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
}

/*验证管理员*/
-(void)getVerifyadminroleEpumentId:(NSInteger)equipmentId
                        completion:(void(^)(LMJBaseResponse *respons))completion{
    
    NSDictionary *dic = @{@"equipmentId":@(equipmentId)
    };
    [self POST:urlVerifyadminrole parameters:dic completion:^(LMJBaseResponse *response) {
       completion(response);
    }];
    
}

/*获取不是此用户的所有对应的设备用户列表(指纹/密码/卡片)*/
-(void)getEquipmentNottheuserlistEquipmentId:(NSInteger)equipmentId
equipmentUserType:(NSString*)equipmentUserType
userId:(NSInteger)userId
type:(NSInteger)type
                                  completion:(void(^)(LMJBaseResponse *respons, NSArray<EquipmentUserModel*> *users))completion{
    NSDictionary *dic = @{@"equipmentId":@(equipmentId),
                          @"equipmentUserType":equipmentUserType,
                          @"userId":@(userId),
                          @"type":@(type)
       };
       [self GET:urlEquipmentusernottheuserlist parameters:dic completion:^(LMJBaseResponse *response) {
           completion(response,[NSArray yy_modelArrayWithClass:[EquipmentUserModel class] json:response.responseObject[@"data"]]);
       }];
}

/*指纹锁用户换绑用户(用户拉取其他指纹、密码)*/
-(void)getBindappuser:(BindAppUser*)bingReq
           completion:(void(^)(LMJBaseResponse *respons))completion{

    NSDictionary *dic =   [bingReq yy_modelToJSONObject];
    
    [self POST:urlEquipmentuserequipmentuserupdatebindappuser parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
    
}


-(void)getFindequipmentrepairsapplyFamilyID:(NSInteger)familyId
page:(NSInteger)page
size:(NSInteger)size
                                 completion:(void(^)(LMJBaseResponse *respons, NSArray<RepairsApplyModel*> *repair))completion{
    
    NSDictionary *dic = @{@"familyId":@(familyId),
                       @"page":@(page),
                          @"size":@(size)
    };
    [self GET:urlEquipmentrepairsapplypage parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[NSArray yy_modelArrayWithClass:[RepairsApplyModel class] json:response.responseObject[@"data"][@"content"]]);
    }];
}

-(void)getFindEquipmentsubscribeinstallcontactscontacts:(NSInteger)page
                                
                                 completion:(void(^)(LMJBaseResponse *respons, NSArray<RepairsApplyModel*> *repair))completion{
    
    NSDictionary *dic = @{
                          @"page":@(page)
    };
    [self GET:urlEquipmentsubscribeinstalllist parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[NSArray yy_modelArrayWithClass:[RepairsApplyModel class] json:response.responseObject[@"data"][@"content"]]);
    }];
}

/*查找开关门记录*/
-(void)getFindequipmentoperationEquipmentID:(NSInteger)equipmentId
page:(NSInteger)page
                                 completion:(void(^)(LMJBaseResponse *respons, NSArray<EquipmentMessageModel*> *repair))completion{
    
    NSDictionary *dic = @{
                          @"page":@(page),
                          @"equipmentId":@(equipmentId),
                          @"size":@(10)
                          
    };
    [self GET:urlFindequipmentoperationpage parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[NSArray yy_modelArrayWithClass:[EquipmentMessageModel class] json:response.responseObject[@"data"][@"content"]]);
    }];
    
}

/*查找报警记录*/
-(void)getFindequipmentAlarmEquipmentID:(NSInteger)equipmentId
page:(NSInteger)page
                             completion:(void(^)(LMJBaseResponse *respons, NSArray<EquipmentMessageModel*> *repair))completion{
    NSDictionary *dic = @{
                          @"page":@(page),
                          @"equipmentId":@(equipmentId),
                          @"size":@(10)
                          
    };
    [self GET:urlFindequipmentalarmpage parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[NSArray yy_modelArrayWithClass:[EquipmentMessageModel class] json:response.responseObject[@"data"][@"content"]]);
    }];
}

/*设备操作查询*/
-(void)getFindoperationpageEquipmentID:(NSInteger)equipmentId
page:(NSInteger)page
                             completion:(void(^)(LMJBaseResponse *respons, NSArray<EquipmentMessageModel*> *repair))completion{
    NSDictionary *dic = @{
                          @"page":@(page),
                          @"equipmentId":@(equipmentId),
                          @"size":@(10)
                          
    };
    [self GET:urlFindOperationpage parameters:dic completion:^(LMJBaseResponse *response) {
        completion(response,[NSArray yy_modelArrayWithClass:[EquipmentMessageModel class] json:response.responseObject[@"data"][@"content"]]);
    }];
}

/*取消预约安装*/
-(void)getcancelEquipmentsubscribeinstallapplyID:(NSInteger)installid
completion:(void(^)(LMJBaseResponse *respons))completion{
    
    
    NSDictionary *dic =   @{@"id":@(installid)};
    
    [self POST:urlcancelEquipmentsubscribeinstallapply parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
}

/*取消设备保修*/
-(void)getcancelEquipmentrepairsapplyID:(NSInteger)equId
completion:(void(^)(LMJBaseResponse *respons))completion{
    
    NSDictionary *dic =   @{@"id":@(equId)};
    
    [self POST:urlCancelequipmentrepairsapply parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
}

/*获取设备详情*/
-(void)getEquipmentinfoWithEqipmentID:(NSInteger)equipID
                           completion:(void(^)(LMJBaseResponse *respons,EquipmentModel*mdoel))completion{
    
    NSDictionary *dic =   @{@"equipmentId":@(equipID)};
    
    [self GET:urlcancelEquipmentsubscribeinstallapply parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response,[EquipmentModel yy_modelWithJSON:response.responseObject[@"data"]]);
    }];
}

//urlSynchronizeappuser
/*app发起同步设备用户*/
-(void)getEquipmentSynchronizeappuserEqipmentID:(NSInteger)equipID
                                     completion:(void(^)(LMJBaseResponse *respons,EquipmentModel*mdoel))completion{
    
    NSDictionary *dic =   @{@"equipmentId":@(equipID)};
    [self POST:urlSynchronizeappuser parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response,[EquipmentModel yy_modelWithJSON:response.responseObject[@"data"]]);
    }];
}

-(void)getEquipmenttimingEqipmentID:(NSInteger)equipID
                         completion:(void(^)(LMJBaseResponse *respons,EquipmentModel*mdoel))completion{
    
    
    NSDictionary *dic =   @{@"equipmentId":@(equipID)};
    [self POST:urlEquipmenttiming parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response,[EquipmentModel yy_modelWithJSON:response.responseObject[@"data"]]);
    }];
}

//根据用户删除设备用户
-(void)getEquipmentEeleteequipmentuserbyuserId:(NSInteger)userId
type:(NSInteger)type
equipmentId:(NSInteger)equipmentId
                           deleteEquipmentUser:(BOOL)isDelete
                                    completion:(void(^)(LMJBaseResponse *respons))completion{
    
    NSDictionary *dic =   @{@"userId":@(userId),
                            @"type":@(type),
                            @"equipmentId":@(equipmentId),
                            @"deleteEquipmentUser":isDelete?@"true":@"false"
    };
    [self POST:urlEeleteequipmentuserbyuser parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
    
}

//指纹锁用户绑定app用户或游客用户
-(void)getEquipmentuserbindappuserEquipuserId:(NSInteger)userId
userId:(NSInteger)useid
type:(NSInteger)type
                                   completion:(void(^)(LMJBaseResponse *respons,EquipmentUserModel *userModel))completion{
    
    NSDictionary *dic =   @{@"id":@(userId),
                            @"userId":@(useid),
                            @"type":@(type)
    };
    [self POST:urlEquipmentuserbindappuser parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response,[EquipmentUserModel yy_modelWithJSON:response.responseObject[@"data"]]);
    }];
    
}

//操作结束
-(void)getendingoperatinEquipuserId:(NSInteger)equipmentId
commandType:(NSInteger)commandType
busiType:(NSInteger)busiType
                         completion:(void(^)(LMJBaseResponse *respons))completion{
    
    NSDictionary *dic =   @{@"equipmentId":@(equipmentId),
                            @"commandType":@(commandType),
                            @"busiType":@(busiType)
    };
    [self POST:urlendingOperation parameters:dic  completion:^(LMJBaseResponse *response) {
        completion(response);
    }];
}
@end
